package com.google.code.shardbatis;

import com.google.code.shardbatis.bean.UserBean;
import com.google.code.shardbatis.mapper.UserMapper;
import com.google.code.shardbatis.util.DBTools;
import org.apache.ibatis.session.SqlSession;

import java.util.Arrays;
import java.util.List;

public class App {
    public static void main(String[] args) {
        test3();
    }


    private static void test1() {
        try (SqlSession session = DBTools.getSession();) {
            UserMapper userMapper = session.getMapper(UserMapper.class);

            UserBean userBean = new UserBean();
            userBean.setClientSn(2599897L);
            userBean.setAge(10);
            userBean.setId(1111111L);
            userBean.setSex("男");
            userBean.setUserName("张三");
            userMapper.insertUser(userBean);
            session.commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void test2() {
        try (SqlSession session = DBTools.getSession();) {
            UserMapper userMapper = session.getMapper(UserMapper.class);
            UserBean userBean = userMapper.selectUserById(1);
            System.out.println(userBean);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void test3() {
        try (SqlSession session = DBTools.getSession();) {
            UserMapper userMapper = session.getMapper(UserMapper.class);
            List<UserBean> userBeanList = userMapper.selectUserByIdList(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L));
            System.out.println(userBeanList);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
